package com.dawn.module.hospital.controller.app.order;

import com.dawn.framework.common.pojo.CommonResult;
import com.dawn.module.hospital.controller.app.base.BaseController;
import com.dawn.module.hospital.service.RefundService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * @description:
 * @author: cnsu-cmh
 * @time: 2024/8/19 10:09
 */
@Tag(name = "订单审核APP - bh")
@RestController
@RequestMapping("/bh/pay")
@Validated
@Slf4j
public class AppOrderExamineController extends BaseController {

    @Autowired
    private RefundService refundExamineService;

    @GetMapping("/refund/examine/{examineId}/detail")
    @Operation(summary = "查询退费申请订单详情")
    public CommonResult detail(@PathVariable Long examineId) {
        return refundExamineService.getExamineDetail(examineId);
    }

    @PostMapping("/refund/examine/{examineId}/examine")
    @Operation(summary = "退款审核")
    public CommonResult examine(@PathVariable Long examineId,@RequestParam(value = "userId", required = true) Long userId) {

        CommonResult haveResult = refundExamineService.isHaveExamine(userId);
        if(haveResult.isError()){
            return haveResult;
        }
        return refundExamineService.examine(examineId,userId);
    }

}
